package com.gml.jdk.lambda;

/**
 * @ClassName : Test1
 * @Description : lambda测试1
 * @Author : gml
 * @Date: 2020-10-22 15:59
 */
public class Test1 {

    @FunctionalInterface
    private interface SingleReturnSingleParmeter{

        public int test(int a);

        public int hashCode();

        String toString();
    }

    private static class Impl implements SingleReturnSingleParmeter{

        public int test(int a) {
            return a;
        }
    }

    public static void main(String[] args) {
        //1.显示实现类对象
        SingleReturnSingleParmeter singleParmeter = new Impl();
        //2.匿名内部实现类
        SingleReturnSingleParmeter singleParmeter1 = new SingleReturnSingleParmeter() {
            public int test(int a) {
                return a;
            }
        };
        //3.使用lambda表达式实现
        SingleReturnSingleParmeter singleParmeter2 = b -> b;

        System.out.println(singleParmeter.test(1));
        System.out.println(singleParmeter1.test(1));
        System.out.println(singleParmeter2.test(1));


    }

    private interface Test2{

    }
}
